<template>
  <div class="box-container">
    <el-card style="max-width: 1000px;margin:10px 0;height: 30px;padding-left: 20px">
      收到的赞
    </el-card>

    <el-card style="max-width: 1000px;min-height: 200px;padding: 20px">
      <div class="reply-item" v-for="item in likeInfoList" :key="item.likeContentId">
        <div class="box">
          <div class="avatar">
            <img :src="item.userAvatars[0]" :alt="item.supporterNicknames[0]" width="60" height="60">
          </div>
          <div class="reply-info">
            <div class="reply-info-title">
<!--              <span class="reply-nickname" v-for="subItem in item.supporterNicknames" :key="subItem">{{subItem}}</span>&nbsp;&nbsp;&nbsp;-->
              <span class="reply-nickname">{{item.supporterNicknames[0]}} <span v-if="item.supporterIds.length > 1">，</span> {{item.supporterNicknames[1]}}</span>&nbsp;&nbsp;&nbsp;
              <span v-if="item.supporterIds.length > 2">等总计 {{item.supporterIds.length}} 人</span>  赞了我的{{ typeMap[item.likeType] }}
            </div>
            <div class="reply-info-content">

            </div>
            <div class="reply-info-footer">
              <div class="datetime">{{item.createTimes[0]}}</div>
              <div class="replyIt">
                <el-icon><ChatRound /></el-icon>回复
              </div>
              <div class="like">
                <el-icon><Pointer /></el-icon>点赞
              </div>
            </div>
          </div>

          <el-image  @click="toDetail(item.likeContentId)" style="height: 60px;width: 100px;cursor:pointer;" :src="item.likeContent" v-if="item.likeType === 1" fit="cover"></el-image>
          <div style="width: 100px" v-if="item.likeType === 2">
            <div class="source-content" @click="toSourceComment(item.likeType,item.likeContentId)">
              {{item.likeContent}}
            </div>
          </div>
        </div>
        <el-divider />
      </div>

    </el-card>
  </div>
</template>
<script setup>
import {onMounted, ref} from "vue";
import {ChatRound} from "@element-plus/icons-vue";
import {getLikeList} from "@/api/api.js";
import {useRouter} from "vue-router";

const likeInfoList1 = ref([
  {
    id:1,
    replierId:1,
    replierAvatar:"/img/avatar2.webp",
    replierNickName:"每天都要开心啊",
    sourceContentId:0,
    sourceContentType:2,
    sourceContent:"你好吗csnadkcjnakjcankl才能打开cdacanjkcnaklcmadslcnalk差点就爱看",
    replyTime:'2023年5月16日 16:55'
  },
  {
    id:1,
    replierId:1,
    replierAvatar:"/img/avatar2.webp",
    replierNickName:"每天都要开心啊",
    sourceContentId:0,
    sourceContentType:2,
    sourceContent:"你好吗csnadkcjnakjcankl才能打开cdacanjkcnaklcmadslcnalk差点就爱看",
    replyTime:'2023年5月16日 16:55'
  },
  {
    id:1,
    replierId:1,
    replierAvatar:"/img/avatar2.webp",
    replierNickName:"每天都要开心啊",
    sourceContentId:0,
    sourceContentType:2,
    sourceContent:"你好吗csnadkcjnakjcankl才能打开cdacanjkcnaklcmadslcnalk差点就爱看",
    replyTime:'2023年5月16日 16:55'
  },
])
const likeInfoList = ref([
  {
    supporterIds:[],
    supporterNicknames:[],
    userAvatars:[],
    likeType:0,
    likeContentId:0,
    likeContent:'',
    createTimes:[]
  }
])
const typeMap = {
  1:"视频",
  2:"评论",
  3:"动态",
  5:"弹幕"
}

onMounted(async ()=>{
 const res = await getLikeList()
  console.log(res)
  likeInfoList.value = res.data
})

const router = useRouter()
const toDetail = (videoId) => {
  router.push({
    name:'video',
    query:{
      videoId
    }
  })
}

const toSourceComment = (typeId,sourceContentId) => {
  router.push({
    path:"/message/likeDetail",
    query:{
      contentId:sourceContentId,
      type:typeId,
    }
  })
}



</script>
<style lang="scss" scoped>
:deep(.el-card__body){
  padding: 0;
}
.el-card{
  --el-card-padding:10px
}
.el-card .el-card__body{
  padding: 0;
}
.reply-item .box{
  display: flex;
  box-sizing: border-box;
  width: 100%;
  height: 80px;
  justify-content: space-between;
  .avatar{
    box-sizing: border-box;
    //padding: 20px;
    width: 60px;
    height: 60px;
    overflow: hidden;
    border-radius: 60px;
    //margin-right: 0px;
  }
  .reply-info{
    box-sizing: border-box;
    width: 750px;
    height: 80px;
    //overflow: hidden;
    //background-color: black;
    .reply-info-title{
      height: 30px;
      .reply-nickname{
        color: black;
        font-weight: bold;
        font-size: 14px;
      }
    }
    .reply-info-content{
      height: 30px;
      color: gray;
    }
    .reply-info-footer{
      color: gray;
      font-size: 12px;
      display: flex;
      .datetime{
        width: 150px;
      }
      .replyIt{
        width: 60px;
      }
      .like{
        width: 60px;
      }
    }
  }
  .source-content{
    box-sizing: border-box;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 50px;
    height: 60px;
    line-height: 20px;
    cursor: pointer;
  }
}
.el-divider--horizontal{
  margin:15px 0;
}
</style>

<!--经典修改css变量值的方式控制css-->

